import request from "@/utils/request";

//登录
export function userLoginService(userRequest) {
    // console.log(userRequest)
    return request({
        url: '/user/login',
        method: 'post',
        data: userRequest,
        headers: {
            'Content-Type': 'application/json'
        }
    })
}

//发送邮件
export function sendEmailService(email) {
    return request({
        url: '/user/sendEmail',
        method: 'post',
        params: email
    })
}

//注销账号
export function cancelAccountService({ code, email, pwd }) {
    return request({
        url: '/user/cancelAccount',
        method: 'post',
        data: { code, email, pwd }
    })
}

//找回密码
export function modifyPasswordService({ code, email, newPwd }) {
    return request({
        url: '/user/modifyPassword',
        method: 'post',
        data: { code, email, newPwd }
    })
}

//获取用户信息
export function getUInfo() {
    return request({
        url: '/user/getUserInfo',
        method: 'get',
    })
}

//修改用户个人信息(个人信息页)
export function changeUInfoService({ uid, nickname, realname, gender, phone, email, intro, ability }) {
    return request({
        url: '/user/changeInfo',
        method: 'post',
        data: { uid, nickname, realname, gender, phone, email, intro, ability }
    })
}
//完善用户个人信息（首次登录）
export function loginAfterPerfectInfo({ uid, nickname, realname, gender, phone, email, intro, ability }){
    return request({
        url:'/user/loginAfterPerfectInfo',
        method:'post',
        data:{ uid, nickname, realname, gender, phone, email, intro, ability }
    })
}

//修改密码
export function changeUPwdService({ uid, originalPwd, newPwd, code }) {
    return request({
        url: '/user/modifyPwByOriginalPw',
        method: 'post',
        data: { uid, originalPwd, newPwd, code }
    })
}

//根据学号、工号获取姓名
export function getUsernameById(id) {
    return request({
        url: '/user/getUsernameById',
        method: 'get',
        params: {
            id
        }
    })
}








